********************************************************************************
*********			  		APPENDIX FIG G.3 - VARIATION IN TIME SAVINGS 
*********								AND RELIABILITY      	********
********************************************************************************
use ".\data\clean\I10W_laneuse_dataset_15nov14_wcensus", clear
merge m:1 date hour using ".\data\clean\HV_ML_reliab.dta", keep(1 3) nogen 
gen reliabilityML=dist/p20_speedML-dist/p50_speedML
gen reliabilityHV=dist/p20_speedHV-dist/p50_speedHV
gen reliability_diff=reliabilityML-reliabilityHV
la var hour "Hour of ExpressLanes Entry"
*WTP calculation
gen TT_dif_hr=dist/MLspeed-dist/ELspeed
gen WTP2=charged_toll/TT_dif_hr
drop if ELspeed==.
drop if TT_dif_hr==.
drop if holiday==1
la var TT_dif_hr "Time in Hours"
la var reliability_diff "Reliability"
drop if dow==0|dow==6
keep if acct_type=="PRIVATE"&occupancy~="HOV-3"
keep if hour>4 & hour<9

collapse TT_dif_hr reliability_diff dist,by(rt_id hour min date) // do this first so that we don't get hours or rt_id's overrepresented based on high demand days
collapse TT_dif_hr reliability_diff dist,by(rt_id hour)
g TT_dif_min=TT_dif_hr*60
g reliability_diff_min=reliability_diff*60
drop if rt_id==7
g TT_difpm=TT_dif_min/dist
g reldifpm=60*reliability_diff_min/dist
format reldifpm %2.0f
format TT_difpm %3.1f

twoway (line TT_difpm hour if rt_id==2) ///
	(line TT_difpm hour if rt_id==3) ///
	(line TT_difpm hour if rt_id==4, lp(dash)) ///
	(line TT_difpm hour if rt_id==5) ///
	(line TT_difpm hour if rt_id==8, lp(dash_dot)) ///
	(line TT_difpm hour if rt_id==9, lp(longdash)) ///
	(line TT_difpm hour if rt_id==10, lp(dash)) ///
	(line TT_difpm hour if rt_id==12) ///
	(line TT_difpm hour if rt_id==13) ///
	(line TT_difpm hour if rt_id==14) ///
	(line TT_difpm hour if rt_id==17, lp(longdash_dot)), ///
	legend(off) xsc(r(5 8.7)) ysc(r(-.2 1.2)) ylabel(0(.25)1) ///
	ytitle("Travel Time Difference per Mile in Minutes") ///
	text(1.087 8  "Rt. 2 - 3.5 mi.",place(east)) ///
	text(0.921 8  "Rt. 3 - 6.2 mi.",place(east)) ///
	text(0.821 8  "Rt. 12 - 2.7 mi.",place(east)) ///
	text(0.765 8  "Rt. 4 - 6.6 mi.",place(east)) ///
	text(0.687 8  "Rt. 5 - 9.68 mi.",place(east)) ///
	text(0.612 8  "Rt. 8 - 3.7 mi.",place(east)) ///
	text(0.44 8  "Rt. 14 - 6.2 mi.",place(east)) ///
	text(0.39 8  "Rt. 10 - 7.1 mi.",place(east)) ///
	text(0.34 8  "Rt. 9 - 4.0 mi.",place(east)) ///
	text(0.29 8  "Rt. 17 - 3.1 mi.",place(east)) ///
	text(.24 8  "Rt. 13 - 3.1 mi.",place(east)) plotregion(style(none))  ///
	name(TTDiffbyhourroute, replace) xlabel(5 "5 AM" 6 "6 AM" 7 "7 AM"  8 "8 AM")
twoway (line reldifpm hour if rt_id==2) ///
	(line reldifpm hour if rt_id==3) ///
	(line reldifpm hour if rt_id==4, lp(dash)) ///
	(line reldifpm hour if rt_id==5) ///
	(line reldifpm hour if rt_id==8, lp(dash_dot)) ///
	(line reldifpm hour if rt_id==9, lp(longdash)) ///
	(line reldifpm hour if rt_id==10, lp(dash)) ///
	(line reldifpm hour if rt_id==12) ///
	(line reldifpm hour if rt_id==13) ///
	(line reldifpm hour if rt_id==14) ///
	(line reldifpm hour if rt_id==17, lp(longdash_dot)), ///
	legend(off) xsc(r(5 8.7))  plotregion(style(none)) ///
	ytitle("Reliability per Mile in Seconds") ///
	text(19 8  "Rt. 12 - 2.7 mi.",place(east)) ///
	text(18 8  "Rt. 9 - 4.0 mi.",place(east)) 	///
	text(17 8  "Rt. 10 - 7.1 mi.",place(east)) ///
	text(16 8  "Rt. 14 - 6.2 mi.",place(east)) ///
	text(15 8  "Rt. 4 - 6.6 mi.",place(east)) ///
	text(14 8  "Rt. 3 - 6.2 mi.",place(east)) ///
	text(13 8  "Rt. 8 - 3.7 mi.",place(east)) ///
	text(12 8  "Rt. 2 - 3.5 mi.",place(east)) ///
	text(11 8  "Rt. 17 - 3.1 mi.",place(east)) ///
	text(10 8  "Rt. 5 - 9.68 mi.",place(east)) ///
	text(9 8  "Rt. 13 - 3.1 mi.",place(east))  xlabel(5 "5 AM" 6 "6 AM" 7 "7 AM" 8 "8 AM") ///
	name(reliabDiffbyhourroute, replace)

graph combine TTDiffbyhourroute  reliabDiffbyhourroute, rows(2)
graph export ".\results\appendix\figs\AFG3.png", width(2550) replace
putexcel set ".\results\appendix\AppendixFigsTabs.xlsx", sheet("Appendix Figure G.3") modify
  putexcel A1 = picture(".\results\appendix\figs\AFG3.png")
